package cc.chenwenxi.mypi.appium.listener;

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.events.api.general.ElementEventListener;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

/**
 * 监听与控件相关的一些操作(如：点击、发送文本)
 */
@Slf4j
public class 控件Listener implements ElementEventListener {

    @Override
    public void beforeClickOn(WebElement webElement, WebDriver webDriver) {
        AndroidElement e = (AndroidElement) webElement;
//        log.info("点击前:{}",webElement);
    }

    @Override
    public void afterClickOn(WebElement webElement, WebDriver webDriver) {
//        log.info("点击后:{}",webElement);
    }

    @Override
    public void beforeChangeValueOf(WebElement webElement, WebDriver webDriver) {

    }

    @Override
    public void beforeChangeValueOf(WebElement webElement, WebDriver webDriver, CharSequence[] charSequences) {

    }

    @Override
    public void afterChangeValueOf(WebElement webElement, WebDriver webDriver) {

    }

    @Override
    public void afterChangeValueOf(WebElement webElement, WebDriver webDriver, CharSequence[] charSequences) {

    }

    @Override
    public void beforeGetText(WebElement webElement, WebDriver webDriver) {
        AndroidElement e = (AndroidElement) webElement;
        log.info("获取Text前;{}",e);
    }

    @Override
    public void afterGetText(WebElement webElement, WebDriver webDriver, String s) {
        AndroidElement e = (AndroidElement) webElement;
        log.info("获取Text后;{}",e);
    }

}
